home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1225_InterfaceBuilder_file_owner.rtf < prev    next >
Text File  |  1995-06-12  |  4KB  |  34 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\fmodern Ohlfs;}
  2. \paperw10780
  3. \paperh9360
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;\red83\green83\blue83;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc1\cf1 Q:  What is the "file's owner" of a .nib file?\
  8. \
  9. A: The .nib's file's owner is an object that's external to the .nib file that's the conduit between objects in the .nib file and the other objects in your application. \
  10. \
  11. Each .nib file has one, and only one, owner.  For small applications, the owner is generally NXApp, the application object itself, although it can be an object of any class.  The owner is the only external object that may be the explicit target of action messages from Controls within the .nib file.  The owner may also have outlets that are initialized at runtime to the id's of objects within the .nib file. \
  12. \
  13. A .nib file is actually an archived collection of objects (windows, panels, controls, etc) that you designed in InterfaceBuilder.  When that file is unarchived at runtime and those objects are loaded, some object needs to "own" them.  For example, the main menu is loaded and owned by NXApp.  When you only have one .nib file, actually all objects are loaded and owned by NXApp.  When you have multiple .nib files (like /NextDeveloper/Examples/Draw), you explicitly set the owner of each file.  The owner is like the "shepherd" of the objects in its file.  The owner sends messages to its objects (makeKeyAndOrderFront: to panels, for example) and it also can receive messages from its object (a button that sent its target method "quit:" to the file's owner, for example).  As usual, you make these connections in InterfaceBuilder. \
  14. \
  15. The file's owner is the only link between those objects and objects elsewhere in the other .nib files of this application.  For example, you could create an info panel in a separate .nib module, and have a custom object Controller which owns that .nib file.  Your main menu item "Info..." is in the main .nib file and doesn't know about the Info panel because it is in a separate .nib file.  However, the main menu can send a message to the Controller object, which, in turn, sends a message to the info panel telling it to display itself.\
  16. \
  17. Why would you choose to use separate .nib files?  At launch time, your entire .nib file (all the panels, menus, buttons, whatnot) is unarchived.  This may inefficiently squander your precious time and memory.  If you have a panel that is sparsely used, you may instead want to place it in a separate nib module and load it when, and if, it is needed.\
  18. \
  19. InterfaceBuilder modules also allow you to create custom panels, windows, and objects that are reusable.  You could place the panel in a nib module and design a custom object that will control and own it, and then by instantiating that object and reusing the .nib module file, you can add that panel and its functionality to any application you create.\
  20. \
  21. In NEXTSTEP Release 2, look at the two-.nib-file example of the Text Editor in the InterfaceBuilder tutorial (Chapter 8 of the NeXTstep Concepts manual) as a guide.\
  22. \
  23. In NEXTSTEP Release 3, the InterfaceBuilder tutorial is covered in Chapter 17 of the Development Tools and Techniques book (the on-line location is /NextLibrary/Documentation/NextDev/DevTools/17_TextApp).\
  24. \
  25. In all versions, see /NextDeveloper/Examples/Draw for a more advanced use.\
  26. \
  27. See also ../Development_Environment/creating_nib_modules.rtf.\
  28. \
  29. QA510    \
  30. \
  31. Valid for 1.0, 2.0, 3.0, 3.1\
  32. \
  33.  
  34.